new Vue({
  el: "#app",
  data() {
    return {
      form: {
        SQLSerialNumber: "P_business_traceability_acquisition_order_detail",
        PaginationNumber: 1, //页数
        RowAmount: 20, //每页数据条数
        Condition: "",
        ExtensionCondition: "",
      },
      total: 0,
      tableData: [], //表格数据
      loading: false,
      use: decodeURI($.cookie("use")),
    };
  },
  mounted() {
    this.getList(); //前端分页
  },
  methods: {
    handleDelete(index, row) {
      const _this = this;
      console.log(index, row);
      row.Row_Status = "1";
      console.log(row);
      // delete row.Operation_Datetime;
      // delete row.Operation_Datetime_Original;
      // delete row.Operation_ID;
      // delete row.Operation_ID_Original;
      let lArray = new Array();
      lArray.push(row);
      let lJSONObject_base_EdibleMushroomPurchase = new Object();
      lJSONObject_base_EdibleMushroomPurchase.base_EdibleMushroomPurchase =
        lArray; //换表
      let lJSONObject_DataSet = new Object();
      lJSONObject_DataSet.Modify = lJSONObject_base_EdibleMushroomPurchase;
      console.log(lJSONObject_DataSet);
      //   return;
      $.ajax({
        headers: {
          AccessToken: $.cookie("token"), //会将数据转换为query string
        },
        url: "https://service.kdddy.cn/donghui/clientOperation/generalSaveForClient",
        type: "POST",
        data: {
          Data: JSON.stringify(lJSONObject_DataSet),
        },
        success: function (Result) {
          console.log(Result);
          if (Result.Status == "success") {
            _this.tableData.splice(index, 1);
          }
        },
        // complete: function (XMLHttpRequest) {
        //   requestPretreatment(XMLHttpRequest); //config/config.js 响应预检
        // },
        dataType: "json",
      });
    },
    // sgd() {},
    onSerach() {
      //查询方法
      this.form.PaginationNumber = 1;
      this.getList(this.form);
    },
    handleSizeChange(val) {
      this.form.PaginationNumber = 1;
      this.form.RowAmount = val;
      this.getList(this.form);
    },
    handleCurrentChange(val) {
      this.form.PaginationNumber = val;
      this.getList(this.form);
    },
    Add() {
      //添加
      window.location.href = "add.html";
    },
    Edit(ID_Number) {
      sessionStorage.setItem("ID_Number", ID_Number);
      window.location.href = "edit.html?ID_Number=" + ID_Number;
    },

    //查询全部收购单
    getList() {
      let Enterprise_Info_SerialNumber = sessionStorage.getItem(
        "Enterprise_Info_SerialNumber"
      );
      //换页方法
      const _this = this;
      $.ajax({
        headers: {
          AccessToken: $.cookie("token"), //会将数据转换为query string
        },
        url: "https://service.kdddy.cn/donghuiForRequest/Purchase/GetAll",
        type: "get",
        data: {
          pageSize: 100,
          pageNumber: 1,
          id: Enterprise_Info_SerialNumber,
        },
        success: function (Result) {
          console.log(Result);
          _this.tableData = Result.Data;
          _this.total = Result.totals;
        },
        complete: function (XMLHttpRequest) {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },
    Operate(command, row) {
      if (command == "edit") {
        this.Edit(row.ID_Number);
      }
    },
  },
});
